<%@page import="cz.acies.genea.data.process.*"%>
<%@page import="cz.acies.genea.data.dao.*"%>
<%@page import="org.apache.commons.beanutils.BeanUtils"%>
<%@ page language="java" session="true" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.google.gson.*"%>

<%@ page pageEncoding="UTF-8" %>
<% request.setCharacterEncoding("UTF-8");  %>
<% response.setCharacterEncoding("UTF-8");  %>
<%
Gson gson = new Gson();
Map<String, Object> params = new HashMap<String, Object>();
Enumeration<String> e = request.getParameterNames();
while (e.hasMoreElements()) {
	String key =  e.nextElement();
	params.put(key, request.getParameter(key));
}
String processId = (String) params.get("processId");
GedPersonDAO dao = new GedPersonDAO(); 
//System.out.println("processId:"+processId);

PersonProcessor process = new PersonProcessor(); 
if (processId.equals("doAppend")) {
	/*
	//System.out.println("params: "+params);
	ContactRecord record = new ContactRecord();
	BeanUtils.populate(record, params);
	String id = dao.insert(record);
	List<ContactRecord> records = dao.selectAll();
	out.println(""+gson.toJson(records));
	*/
} else if (processId.equals("doUpdate")) {
	//System.out.println("params: "+params);
    process.doUpdate(params);
	/*
	ContactRecord record = new ContactRecord();
	BeanUtils.populate(record, params);
	String id = dao.update(record);
	List<ContactRecord> records = dao.selectAll();
	out.println(""+gson.toJson(records));
	*/
} else if (processId.equals("selectAll")) {
	//process.execute(params);
	/*
	List<ContactRecord> records = dao.selectAll();
	String data = "" + gson.toJson(records);
	out.println(data);
	*/
} else if (processId.equals("selectByWhere")) {
	
	/*
	List<ContactRecord> records = dao.selectAll();
	Map<String, String> where = new LinkedHashMap<String, String>();
	if (params.containsKey("countryCode")) where.put("countryCode", ""+params.get("countryCode"));
	if (!where.isEmpty()) {
	    records = dao.selectByWhere(where);
	}
    String data = "" + gson.toJson(records);
    out.println(data);
    */
} else if (processId.equals("selectById")) {
		
}
%>
